package com.tivyso.testing.mock.generator.componentfilter;

import java.util.regex.Pattern;

import org.apache.commons.lang.Validate;

public class RegexComponentFilter implements IComponentFilter{
	
	protected final Pattern pattern;
	
	public RegexComponentFilter(Pattern pattern){
		Validate.notNull(pattern);
		this.pattern = pattern;
	}
	
	public RegexComponentFilter(String regex){
		Validate.notNull(regex);
		this.pattern = Pattern.compile(regex);
	}

	public boolean match(String className) {
		return this.pattern.matcher(className).matches();
	}
}
